from math import *
from timeit import itertools
import functools
import sys
 
def getValues(v) :
    if v.find(',') == -1 :
        return [int(v)]
    else :
        v = v.split(',')
        return xrange(int(v[0]),int(v[1])+1)

        
D_INPUT = True
if D_INPUT:
    Func = raw_input()
    Vars = raw_input()
else:
    Func = "Param"
    Vars = "Param=3,214"


if len(Vars) == 0 :
    print eval(Func)
    exit()

Vars = map(lambda v: v.split("="), Vars.split())
varNames = ",".join(map(lambda v: v[0],Vars))  
varValues = map(lambda v: getValues(v[1]),Vars)

    
exec("def func(%s): return %s" % (varNames, Func))

                   
fl_first = True
fmax = 0
for i in itertools.product(*varValues):
    try:            
        fval = func(*i)
    except :
        continue
    else :
        if fl_first :
            fmax = fval
            fl_first = False
        else :
            if fmax < fval : fmax = fval
 
print fmax


               
